home *** CD-ROM | disk | FTP | other *** search
/ MaxiMac 2001 March / MaxiMac 112.iso / Macworld on CD n°112 / Applications (Mac OS Classic) / SiteCam 6.0 démo / Extras / Sample AppleScripts / CreatePano.script < prev    next >
Encoding:
Text File  |  2000-09-26  |  5.9 KB  |  234 lines  |  [TEXT/CWIE]

  1. -- This script requires SiteCam 5.1 or higher
  2.  
  3. -- Specify start and stop degree settings (reverse for non-inverted use)
  4. set startDegrees to 100        -- (-100 to 100)
  5. set stopDegrees to -100        -- (-100 to 100)
  6.  
  7. -- The number of pictures to use in your panorama
  8. set numFrames to 6
  9.  
  10. -- Should a panorama file be generated (requires an existing SiteZAP-Stitch pano document)
  11. -- You can set this to false if you just want to test the picture taking
  12. set makePano to true
  13.  
  14.  
  15. -- The captions to put on the "key frame"  . Currently only one caption is used, but you can use more 
  16. -- by adding them in order where the "" are.  Before using, set the size, color, style, etc.
  17. -- in SiteCam's "Pano" document.
  18. -- We put the caption in using the script because you only want the caption on one image.
  19. set captionList to {"Created with SiteZAP", "", "", ""}
  20.  
  21.  
  22. -- The captionFrame is the frame that we put the above captions on.  
  23. -- The captions should be already be set up (position, color, size, etc) in the Pano SiteCam document.
  24. set captionFrame to 4
  25.  
  26.  
  27. -- Set to true if you want to keep QTVR Authoring studio open at all times.
  28. set keepQTVROpen to true
  29.  
  30.  
  31. -------------------------------------------------------------------------------------
  32. -- script source code --  Modify at your own risk -- ©1999 Brad Lowe Rearden Technology
  33. -------------------------------------------------------------------------------------
  34.  
  35.  
  36. with timeout of 6000 seconds
  37.     -- Get path to store temp picture files
  38.     set the_path to MakeTempDirectory()
  39.     
  40.     set success to my OpenPanoDocument()
  41.     
  42.     if (success) then
  43.         set success to TakePanoPicts(startDegrees, stopDegrees, numFrames, the_path, captionFrame)
  44.         
  45.         -- if all was well, instruct qtvr-as to build a panorama.
  46.         
  47.         if (success and makePano) then my MakeQTVRPanorama()
  48.     end if
  49.     
  50.     try
  51.         tell application "Finder"
  52.             activate
  53.         end tell
  54.         tell application "SiteCam"
  55.             activate
  56.         end tell
  57.     end try
  58.     
  59. end timeout
  60.  
  61.  
  62.  
  63. -- This is the key frame that we add text or a logo to.
  64. on SetCaptions()
  65.     beep
  66.     tell application "SiteCam"
  67.         repeat with x from 1 to 4
  68.             set message of caption x of document "pano" to (item x of captionList)
  69.         end repeat
  70.     end tell
  71. end SetCaptions
  72.  
  73. -- This is not the key frame.  We delete any text or logos that might exist.
  74. on UnsetCaptions()
  75.     tell application "SiteCam"
  76.         repeat with x from 1 to 4
  77.             set message of caption x of document "pano" to ""
  78.         end repeat
  79.     end tell
  80. end UnsetCaptions
  81.  
  82. -- Attempt to open the SiteCam document "pano".
  83. on OpenPanoDocument()
  84.     if (my OpenDoc("pano") is false) then
  85.         tell application "SiteCam"
  86.             -- Create document "pano" (a quarter size, medium resolution image)
  87.             make new document
  88.             --set width of active document to 320
  89.             -- set height of active document to 240
  90.             set image type of active document to pict
  91.             save active document as "pano"
  92.         end tell
  93.     end if
  94.     return true
  95. end OpenPanoDocument
  96.  
  97.  
  98. on OpenDoc(docName)
  99.     try
  100.         tell application "SiteCam"
  101.             if document docName exists then return true
  102.             open file docName
  103.         end tell
  104.     on error
  105.         return false
  106.     end try
  107.     return true
  108.     
  109. end OpenDoc
  110.  
  111.  
  112.  
  113. on TakePanoPicts(startDegrees, stopDegrees, frames, the_path, keyFrame)
  114.     set success to false
  115.     -- turn off access to the SiteZAP by remote users.
  116.  
  117.     
  118.     try
  119.         
  120.         set unitsPerDegree to 8.8
  121.         
  122.         set startDegrees to checkbounds(startDegrees, -100, 100)
  123.         set stopDegrees to checkbounds(stopDegrees, -100, 100)
  124.         
  125.         set panPos to startDegrees * unitsPerDegree
  126.         set panIncrement to ((stopDegrees - startDegrees) * unitsPerDegree) / frames
  127.         
  128.         tell application "SiteCam"
  129.             set sitezap control to false        -- this turns off user access to the pan/tilt
  130.             set zoom of active pantilt to 0
  131.         end tell
  132.         
  133.         repeat with index from 1 to frames
  134.             tell application "SiteCam"
  135.                 set position of active pantilt to {round (panPos), 0}
  136.                 set panPos to panPos + panIncrement
  137.                 waitticks 30    -- wait a half second for the camera to focus... 
  138.             end tell
  139.             
  140.             try
  141.                 if (index = keyFrame) then
  142.                     SetCaptions()
  143.                 else
  144.                     UnsetCaptions()
  145.                 end if
  146.             end try
  147.             
  148.             if (index < 10) then
  149.                 set indexStr to "0" & index
  150.             else
  151.                 set indexStr to index
  152.             end if
  153.             
  154.             set fileName to (the_path & indexStr & ".pict")
  155.             tell application "SiteCam"
  156.                 take picture with document "pano" as file fileName type pict
  157.                 -- take picture with document "pano" as file filename type pict
  158.             end tell
  159.             
  160.         end repeat
  161.         
  162.         set success to true
  163.     end try
  164.     
  165.     tell application "SiteCam"
  166.         set sitezap control to true    -- important... return user control to SiteZAP controls
  167.     end tell
  168.     
  169.     return success
  170.     
  171. end TakePanoPicts
  172.  
  173. on MakeQTVRPanorama()
  174.     
  175.     -- open QTVR-Stitching Document
  176.     tell application "Finder"
  177.         
  178.         if (file (name of startup disk & ":QuickTime VR Authoring Studio:SiteZAP-Stitch") exists) then
  179.             open file (name of startup disk & ":QuickTime VR Authoring Studio:SiteZAP-Stitch")
  180.         else
  181.             beep
  182.         end if
  183.     end tell
  184.     
  185.     
  186.     -- Use MenuEvents scripting additon to activate the "Stitch Panorama" menu item.
  187.     tell application "QTVR Authoring Studio 1.0.1"
  188.         -- activate
  189.         with timeout of 6000 scene node
  190.             Make Content document "SiteZAP-Stitch"
  191.         end timeout
  192.         
  193.         if (my keepQTVROpen is false) then
  194.             repeat with attempt from 1 to 10
  195.                 if (get (count of windows) < 1) then exit repeat
  196.                 close window 1 saving no
  197.             end repeat
  198.             quit saving no
  199.         end if
  200.         
  201.     end tell
  202.     
  203.     
  204.     
  205.     
  206. end MakeQTVRPanorama
  207.  
  208.  
  209.  
  210. -- Create a temp directory for qtvr images.
  211. on MakeTempDirectory()
  212.     tell application "Finder"
  213.         set the_path to name of startup disk & ":qtvr:"
  214.         set hasFolder to folder the_path exists
  215.         if (not hasFolder) then
  216.             set new_folder to make new folder at startup disk
  217.             set name of new_folder to "qtvr"
  218.             
  219.             -- first time setup...  user must make new QTVR Pano document.
  220.             set makePano to false
  221.         end if
  222.     end tell
  223.     return the_path
  224. end MakeTempDirectory
  225.  
  226. -- Make sure a parameter or value is within specified max/mins.
  227. on checkbounds(inValue, min, max)
  228.     if (inValue < min) then return min
  229.     if (inValue > max) then return max
  230.     return inValue
  231. end checkbounds
  232.  
  233.  
  234.